//click_list_objects.sqf
#include "ACV_Constantes.h"
#include "ACV_ID_main_dlg.h"
private ["_arr","_control","_index","_display","_map","_btn_delete","_odpos","_varname", "_obj","_pos"];
disableSerialization;
_arr = _this select 0;
_control = _arr select 0;
_index   = _arr select 1;
_display = findDisplay ACV_DLG_ID_Main_Dlg;
_map =  _display displayCtrl ACV_DLG_ID_Main_Map;
_btn_delete = _display displayCtrl ACV_DLG_ID_Main_DeleteObjects;
if (_index > -1) then {
	_oldpos = getMarkerPos ACV_MARKER_LOC_Unit;
	call ACV_FNCT_ClearAll_WpMarkers;
	_varname = _control lbData _index;
	call compile format ["_obj = %1",_varname];
	_pos = getpos _obj;
	if (isnil("ACV_MARKER_LOC_Unit")) then {
		ACV_MARKER_LOC_Unit = createMarkerLocal [_varname,_pos] ;
	};
	ACV_MARKER_LOC_Unit setMarkerShapeLocal "ICON";
	ACV_MARKER_LOC_Unit setMarkerTypeLocal "mil_dot";
	ACV_MARKER_LOC_Unit setMarkerPosLocal _pos;
	ACV_MARKER_LOC_Unit setMarkerSizeLocal [0.5,0.5];
	ACV_MARKER_LOC_Unit setMarkerTextLocal _varname;
	ACV_MARKER_LOC_Unit setMarkerColorLocal "ColorYellow";
	ACV_MARKER_LOC_Unit setMarkerAlphaLocal 0.5;
	if (ACV_Move_Map_Auto) then {
		if ((_pos distance [0,0,0]) > 10) then {
			if (((_oldpos distance _pos) > 500) && (!ACV_Filling_Dlg)) then {
				_map ctrlmapanimadd [0.5,1,_pos];
		   		_map ctrlmapanimadd [0.5,0.06,_pos];
		   		ctrlmapanimcommit _map;
			};
		};
	};
};
_btn_delete ctrlEnable (_index > -1); 